//
//  ILGTestModel.m
//  ILGDemo
//
//  Created by HappyWork on 2018/11/9.
//  Copyright © 2018 Happy. All rights reserved.
//

#import "ILGTestModel.h"

typedef void(^ILGTestModelBlock)(NSString *name);

@interface ILGTestModel ()
@property (nonatomic, strong) ILGTestModelBlock block;
@end

@implementation ILGTestModel

- (instancetype)init {
    if (self = [super init]) {
        _testArr = [NSMutableArray array];
        
//        __block ILGTestModel *blockSelf = self;
//        _block = ^(NSString *name) {
//            NSLog(@"%s, name = %@", __func__, name);
//            blockSelf = nil;
//        };
    }
    return self;
}

- (void)dealloc {
    NSLog(@"%s", __func__);
}

- (void)setName:(NSString *)name {
    _name = name;
}

- (void)setAge:(int)age {
    _age = age;
}


#pragma mark - block

- (void)callWithBlock:(ILGTestModelBlock)completion {
    self->_block = completion;
}

- (void)testBlock {
    NSLog(@"arc _block = %@", _block);
    self->_block(@"ZhangSan");
}

- (ILGTestModelBlock)arcBlock {
    int age = 10;
    
    void(^returnBlock)(NSString *name) = ^(NSString *name){
        NSLog(@"ILGTestModelBlock called, age = %d", age);
    };
    return returnBlock;
}

@end
